To go beyond merely displaying an image in a draw widget and allow the user to interact in some way with the displayed image, you must configure the draw widget to generate either button, motion, wheel, or keyboard events:
Wheel events are enabled by setting the WHEEL_EVENTS keyword to WIDGET_DRAW. Once enabled, wheel events are generated when the draw widget has focus and the user rolls the scroll wheel.
Note: Wheel events are enabled only under Microsoft Windows.
The following example uses motion events to update the values of several label widgets as the mouse cursor moves over an image in a draw widget. This and several other features are discussed in the section following the code.
See the file draw_widget_data.pro in the examples/doc/widgets subdirectory of the IDL distribution for the example code. Run this example procedure by entering draw_widget_data at the IDL command prompt or view the file in an IDL Editor window by entering .EDIT draw_widget_data.pro. See Running the Example Code if IDL does not run the program as expected. You may need to enter DEVICE, DECOMPOSED=1 at the IDL command prompt before running this example.
The following things about this example are worth noting:
stash structure, but since the image could be large, we choose to pass a pointer to the image instead. This means we must dereference the pointer variable every time we need to use the image data.